
bool check(struct TreeNode* p,struct TreeNode* q)
{
    if(!p&&!q)
    return true;
    else if(!p||!q)
    return false;
    if(p->val!=q->val)
    return false;
    return check(p->left,q->right)&&check(p->right,q->left);
}
bool isSymmetric(struct TreeNode* root)
{
    if(!root)
    return true;
    struct TreeNode* p=root->left;
    struct TreeNode* q=root->right;
    return check(p,q);
}